/**
 * com.monte.persistence.command.MyBatisQueryComman.java
 * create by FengMy from 2013
 */
package com.monte.persistence.command;

import java.util.List;

import com.monte.persistence.CommandContext;
import com.monte.persistence.PersistenceCommand;
import com.monte.util.StringUtils;

/**
 * @描述: 列表数据查询
 * @author FengMy
 * @since 2013-3-21
 */
public class MyBatisQueryCommand<T> implements PersistenceCommand {
	private String mapper;
	private Object param;
	
	public MyBatisQueryCommand(String mapper, Object param){
		if(StringUtils.isEmpty(mapper)){
			throw new IllegalArgumentException("mybatis mapper could not to be empty");
		}
		this.mapper = mapper;
		this.param = param;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<T> execute(CommandContext context) {
		return context.getSqlSession().selectList(mapper, param);
	}

}
